/**
 * FileName: Grade
 * Author:   xing.yang@vcg.com
 * Date:     2020/6/2 16:07
 * Description:
 */
package com.vcg.vdam.config;

import com.alibaba.fastjson.JSONObject;

import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;

public class Grade {

    private String gradeString;

    private Integer id;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getGradeString() {
        return gradeString;
    }

    public void setGradeString(String gradeString) {
        this.gradeString = gradeString;
    }

//    public static void main(String[] args){
//        ExecutorService executorService = Executors.newFixedThreadPool(5);
//
//        ConcurrentHashMap<String, String> objectObjectConcurrentHashMap = new ConcurrentHashMap<>();
//        objectObjectConcurrentHashMap.put("1","2");
//        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5, 10,
//                300L, TimeUnit.MILLISECONDS,
//                new LinkedBlockingQueue<Runnable>(100));
//
//        for(int i = 1;i<2;i++){
//            threadPoolExecutor.submit(new Runnable() {
//                @Override
//                public void run() {
////                    System.out.println("当前线程的名称是"+Thread.currentThread().getName());
//                    System.out.println("当前线程的名称是"+Thread.currentThread().getName()+"当前活跃线程的数量"+threadPoolExecutor.getActiveCount());
//                }
//            });
//        }
////        Thread.sleep(1000l);
////        threadPoolExecutor.getActiveCount();
//    }

    //测试阻塞队列
//    public static void main(String[] args){
//        LinkedBlockingDeque<String> strings = new LinkedBlockingDeque<>(5);
//        strings.offer("123");
//        try {
//            strings.poll(10000L,TimeUnit.MILLISECONDS);
//            System.out.println("十秒之内");
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        for(int i = 1;i<10;i++){
//            strings.offer(""+i);
////            new Thread(new Runnable() {
////                @Override
////                public void run() {
////
////                    strings.offer(""+1);
////                }
////            }).start();
//        }
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//
//                try {
//                    System.out.println(strings.takeFirst());
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//            }
//        }).start();
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//
//                try {
//                    System.out.println(strings.takeFirst());
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//            }
//        }).start();
//
//        try {
//            Thread.sleep(5000L);
//            strings.offer("我是第一");
//            Thread.sleep(5000L);
//            strings.offer("我是第二");
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        System.out.println(strings.size());
//        System.out.println(strings.poll());


//    }

//    public static void main(String[] args){
//        AtomicInteger ctl = new AtomicInteger(10);
//        int i = 1 & ~10;
//        int i1 = 2 & ~10;
//        int i2 = 12 & ~10;
//        System.out.println(i);
//        System.out.println(i1);
//        System.out.println(i2);
//    }

//    public static void main(String[] args){
////        ExecutorService executorService = Executors.newFixedThreadPool(5);
//        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5, 5,
//                30000L, TimeUnit.MILLISECONDS,
//                new LinkedBlockingQueue<Runnable>());
////        threadPoolExecutor.allowCoreThreadTimeOut(true);
//        threadPoolExecutor.submit(new Runnable() {
//            @Override
//            public void run() {
//                System.out.println("我是任务1");
//            }
//        });
//
//    }

    //测试lock锁得流程
//    public static void main(String[] args){
//
//        ReentrantLock lock = new ReentrantLock();
//
//        lock.lock();
//        System.out.println("我是主线程");
//
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                lock.lock();
//                System.out.println("我已经获取到锁了，我是一线程");
//                lock.unlock();
//            }
//        },"线程一").start();
//
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                lock.lock();
//                System.out.println("我已经获取到锁了；我是二线程");
//                lock.unlock();
//            }
//        },"线程二").start();
//
//
//
//    }
    public static void main(String[] args){
        Grade grade = new Grade();
        grade.setId(345);
        System.out.println(JSONObject.toJSONString(grade));
    }
}
